echo -e "Tumor\tPhi_raw\tCluster_raw\tTitan_Puriy\tTitan_Ploidy\tFacets_purity\tFacets_ploidy" > ${Titan_path}/CheckModel_NonTumor/All_Model.tsv
for Tumor in `cat ${list_nonTumor_file} | grep -v Tumor | awk -F, '{print $1}' | sort -u`
do
echo ${Tumor}
## Facets的纯度
facets_purity=`cat ${facets_purity_path}/Purity_facets.NonTumor.csv | grep -w ${Tumor}  | awk '{print $2}'`
facets_ploidy=`cat ${facets_purity_path}/Purity_facets.NonTumor.csv | grep -w ${Tumor}  | awk '{print $3}'`

## Titan选择的模型以及纯度
cat ${Titan_path}/optimalClusterSolution_NonTumor/${Tumor}_optimalClusterSolution.txt | awk -F'\t' '{OFS="\t"}{print $3,$1,$2,$6,$8,facets_purity,facets_ploidy}' facets_ploidy=${facets_ploidy} facets_purity=${facets_purity} \
| sed '1d' \
>> ${Titan_path}/CheckModel_NonTumor/All_Model.tsv
done

#####################################
## 高倍体
highPurity=0.1

cat ${Titan_path}/CheckModel_NonTumor/All_Model.tsv | head -1 > ${Titan_path}/CheckModel_NonTumor/HighPloidy.tsv
cat ${Titan_path}/CheckModel_NonTumor/All_Model.tsv | grep -v -w Tumor | awk -F'\t' '{OFS="\t"}{if($4>=highPurity)print}' highPurity=${highPurity} \
>> ${Titan_path}/CheckModel_NonTumor/HighPloidy.tsv

export out_path=${Titan_path}/CheckModel_NonTumor/HighPloidy
rm -rf ${out_path}
cat ${Titan_path}/CheckModel_NonTumor/HighPloidy.tsv | grep -v Tumor | awk '{print $1}' | xargs -i -P 20 sh -c '
sh ${scripts_path}/TitanCNA_getAllInfoForCheck.NonTumor.sh {} ${out_path}
'
